import { UserItem } from "./models";
import req, { ResponseData } from "/@/api/req";

export const Api = {
  login: "login",
  userInfo: "getInfo",
  userList: "system/user/list",
  user: "system/user/",
  resetPwd: "system/user/resetPwd",
};

export function handleLogin(data: { username: string; password: string }) {
  return req.commonPostResponse(Api.login, data, { useGlobalLoading: false, withToken: false });
}

export function getUserInfo() {
  return req.commonGetResponse(Api.userInfo, {}, { useGlobalLoading: false });
}

export function getUserDetail(userId: number) {
  return req.commonGet<UserItem>(Api.user + userId, {}, { useGlobalLoading: false });
}

export function resetPwd(data: { userId: number; password: string }) {
  return req.put({
    data,
    url: Api.resetPwd,
  });
}
